package com.always.electrical.energy.utils;

import com.always.electrical.energy.mqtt.res.MqttResponse;
import com.always.electrical.energy.mqtt.res.MqttTaskRes;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.lang.reflect.Type;

public class TypeRefResult<RES extends MqttResponse> extends TypeReference<MqttTaskRes<RES>> {

    protected final Type type;

    public TypeRefResult(ObjectMapper objectMapper, Class<RES> clazz) {
        type = objectMapper.getTypeFactory().constructParametricType(MqttTaskRes.class, clazz);
    }

    @Override
    public Type getType() {
        return type;
    }
}
